package push2java;

/**
 *
 * @author James Pettit
 */
public class Type {

    public static enum Literal {

        INTEGER, FLOAT, BOOLEAN, TYPE, CODE, NAME
    };

    public static boolean isInteger(String s) {
        try {
            Integer.parseInt(s);
        } catch (NumberFormatException ex) {
            return false;
        }
        return true;
    }

    public static boolean isFloat(String s) {
        try {
            Float.parseFloat(s);
        } catch (NumberFormatException ex) {
            return false;
        }
        return true;
    }

    public static boolean isBoolean(String s) {
        return s.equals("true") || s.equals("false");
    }

    public static boolean isType(String s) {
        for (Literal literal : Literal.values()) {
            if (literal.name().equals(s)) {
                return true;
            }
        }
        return false;
    }

    public static boolean equal(Literal literal, String type) {
        return literal.name().equals(type);
    }
}
